package make.money.gold;

import java.util.Arrays;
import java.util.List;

public class DoubleBoolWhere {

    // 条件1 奇偶个数

    /**
     *
     * @param money 集合
     * @param countDouble 偶数的值
     * @return
     */
    public static Boolean jiou(List<Integer> money,List<Integer> countDouble){
        long cou = money.stream().filter(data->{return data%2==0 ;}).count();
        for(Integer integer : countDouble){
            if(integer == (int)cou){
                return true;
            }
        }
        return false;
    }

    /**
     * 去掉集合中尾号一样的数（超过3个的数）
     * @param money
     * @return
     */
    public static Boolean weihao(List<Integer> money){
        int [] a = {0,0,0,0,0,0,0,0,0,0};
        money.stream().forEach(data->a[data%10]++);
        long moneyCout = Arrays.stream(a).filter(date-> date>=3).count();
        return moneyCout == 0?true:false;
    }

    /**
     * 去掉尾号双重复如（1,11 ，2,22）
     * @param money
     * @return
     */
    public static Boolean weihaoDouble(List<Integer> money){
        int [] a = {0,0,0,0,0,0,0,0,0,0};
        money.stream().forEach(data->a[data%10]++);
        long moneyCout = Arrays.stream(a).filter(date-> date>=2).count();
        return moneyCout < 2?true:false;
    }

    /**
     * 排除不要的号码
     * @param money
     * @param shahaos
     * @return
     */
    public static Boolean notNum(List<Integer> money,List<Integer> shahaos){
        List<Integer> moneyList =  ListUtils.unions(money,shahaos);
        return moneyList.size()==money.size()+shahaos.size()?true:false;
    }

    /**
     * 和值取值范围
     * @param money
     * @param min
     * @param max
     * @return
     */
    public static Boolean sumNum(List<Integer> money,int min,int max){
        int sum = money.stream().mapToInt(Integer::intValue).sum();
        if(sum>=min && sum<=max ){return true;}
        return false;
    }

    /**
     * 和值的尾号
     * @return
     */
    public static Boolean sumWeiNum(List<Integer> money,List<Integer> weihaos){
        int sum = money.stream().mapToInt(Integer::intValue).sum();
        for(Integer integer : weihaos){
            if(sum%10==integer){return true;}
        }
        return false;
    }

    // 连续号不要
    public static Boolean lianxu(List<Integer> money){
        for(int i =1;i<=12;i++){

            if ((       money.get(0) + i == money.get(1) && money.get(1) + i == money.get(2))
                    || (money.get(1) + i == money.get(2) && money.get(2) + i == money.get(3))
                    || (money.get(2) + i == money.get(3) && money.get(3) + i == money.get(4))
                    || (money.get(3) + i == money.get(4) && money.get(4) + i == money.get(5))
            ) {
                return false;
            }
        }

        return true;

    }

    /**
     * 求两个集合并集的个数是否符合>=small&&<=big
     * @param money
     * @param arr
     * @param small
     * @param big
     * @return
     */
    public static boolean getFanwei(List<Integer> money,List<Integer> arr,int small,int big){
        List<Integer> moneyList = ListUtils.intersect(money,arr);
        if(moneyList.size()>=small && moneyList.size()<=big){return true;}
        return false;
    }

    /**
     * 超过两个大于count不要
     * @param money
     * @param count
     * @return
     */
    public static boolean getCount(List<Integer> money,int count){
        long sum = money.stream().filter(data->data>=count).count();
        return sum >=2?false:true;
    }

    public static boolean getFanweiGeshu(List<Integer> money,int min,int max,int count){
        long sum = money.stream().filter(data->data>=min&&data<=max).count();

        return sum >=count?false:true;
    }
    public static void main(String[] args) {
        getFanweiGeshu(Arrays.asList(1,32,33),30,33,2);
//        notNum(Arrays.asList(1,2,3),Arrays.asList(4,5));
    }
}
